package personal.vivian.jdkproxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import personal.vivian.logic.LogicClass;

public class ProxyCreator implements InvocationHandler {
    private Object proxy;
    private LogicClass logicClass;

    public ProxyCreator(Object proxy, LogicClass logicClass) {
        this.proxy = proxy;
        this.logicClass = logicClass;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        logicClass.loginMethod();
        return method.invoke(this.proxy,args);
    }
}
